jwt-body-field.js ➔ ???   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
c 1
b 0
f 0
nc 1
dl 0
loc 4
rs 10
nop 2
1
'use strict'
2
3
import chalk from 'chalk'
4
import { Strategy as JwtStrategy, ExtractJwt } from 'passport-jwt'
5
import config from '../../../../config'
6
import logger from 'winston'
7
8
const options = {}
9
options.secretOrKey = config.jwt.secret
10
options.jwtFromRequest = ExtractJwt.fromBodyField('token')
11
12
// e.g /change_password?token=
13
export const jwtBodyFieldStrategy = new JwtStrategy(options, (jwtPayload, next) => {
14
  logger.info('Passport', `${chalk.green('[jwtBodyFieldStrategy]')} payload received: ${jwtPayload}`)
15
  next(null, true)
16
})
17